﻿<Window x:Class="Tambourine.View.TambourineView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:model="clr-namespace:Tambourine.Model"
        xmlns:local="clr-namespace:Tambourine.View"
        Height="600" Width="800"
        Title="{Binding Title}" >

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <DockPanel>
        
        <!-- TOOLBAR -->
        <ToolBar DockPanel.Dock="Top"
                 HorizontalAlignment="Stretch"
                 Height="26">
                 
            <Button ToolTip="Open file"
                Command="{Binding OpenFileCommand}">
                <Image Source="{StaticResource fileopen}" Style="{StaticResource ButtonImageStyle}"/>
            </Button>

            <Button ToolTip="Reload"
                Command="{Binding ReloadFileCommand}">
                <Image Source="{StaticResource reload}" Style="{StaticResource ButtonImageStyle}"/>
            </Button>

            <Separator />

            <Button ToolTip="Export all"
                Command="{Binding ExportAllCommand}">
                <Image Source="{StaticResource excelExportAll}" Style="{StaticResource ButtonImageStyle}"/>
            </Button>

            <Button ToolTip="Export current"
                Command="{Binding ExportOneCommand}">
                <Image Source="{StaticResource excelExportOne}" Style="{StaticResource ButtonImageStyle}"/>
            </Button>

            <Separator />
        </ToolBar>

        <!--RESULT DETAILS ResizeBehavior="CurrentAndNext"-->
        <Expander DockPanel.Dock="Right" 
                  x:Name="detailsExpander" Header="Details"
                  ExpandDirection="Left" Style="{StaticResource DetailsExpanderHeaderAngle}"
                  IsEnabled="False" Margin="0,22,0,0" Expanded="detailsExpander_Expanded" >
            <Expander.Content>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MinWidth="5" />
                        <ColumnDefinition Width="Auto" x:Name="detailsColumn" />
                    </Grid.ColumnDefinitions>
                    <GridSplitter Grid.Column="0" Width="5" ResizeDirection="Columns" />
                    <StackPanel Grid.Column="1">
                        <Label Content="Message:"/>
                        <TextBox Text="{Binding FailureMesssage}" IsReadOnly="True" TextWrapping="WrapWithOverflow" />
                        <Label Content="StackTrace:"/>
                        <TextBox Text="{Binding FailureStackTrace}" IsReadOnly="True" TextWrapping="WrapWithOverflow" />
                    </StackPanel>
                </Grid>
            </Expander.Content>
        </Expander>

        <!-- PIVOT RESULTS -->
        <TabControl Grid.Column="0"
                    x:Name="mainTabControl"
                    ItemsSource="{Binding Data}"
                    IsSynchronizedWithCurrentItem="True" SelectedIndex="0" 
                    SelectedItem="{Binding CurrentMatrix}">
                <TabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}"/>
                    </DataTemplate>
                </TabControl.ItemTemplate>
                <TabControl.ContentTemplate>
                    <DataTemplate>

                        <!--RESULT TABLE-->
                        <DataGrid x:Name="PivotDataGrid" Grid.Column="0"
                                            ItemsSource="{Binding}"
                                            EnableColumnVirtualization="False" EnableRowVirtualization="False"
                                            VirtualizingStackPanel.IsVirtualizing="False"
                                            IsReadOnly="True"
                                            SelectionUnit="Cell" SelectionMode="Single"
                                            RowHeight="20" AutoGeneratingColumn="PivotDataGrid_AutoGeneratingColumn" 
                                            SelectedCellsChanged="PivotDataGrid_SelectedCellsChanged"
                                            />
                    </DataTemplate>
                </TabControl.ContentTemplate>
            </TabControl>
        
    </DockPanel>
</Window>

